<?php
/**
 * Created by PhpStorm.
 * User: lxd
 * Date: 2018/7/24
 * Time: 10:41
 * Comm:
 */

require './vendor/autoload.php';
$clientid   = 'Aa5BPQFD6os1nY77Q_F-x2wMjeHAmsOcmiPkdTtp7N9D-MmSGnZ1-ymVlhWSLF6mI7WHjyigzwh_iAvc';
$secret     = 'EI8GtECPdbGbxoSgXyTQleKrllUFvxXHkYHyti7NPs2jaTZMdNfUsmU7kfNk259TtzTl8ulBxgCg51Va';
$baseUrl    = 'https://ppt.vipwifi.com/paytest/';

//get token
try{
    $config     = [
        'cache.enabled'     => true, //开启token缓存
        'cache.FileName'    => __DIR__ . '/var/'.md5( $clientid ).'.cache',
    ];
    $tokenModel         = new \PayPal\Auth\OAuthTokenCredential( $clientid, $secret );
    $token              = $tokenModel->getAccessToken( $config );
}catch ( Exception $e ) {
    exit( $e->getMessage() );
}


$apiContext     = new \PayPal\Rest\ApiContext( $tokenModel );

$hooks  = \PayPal\Api\WebhookEventType::availableEventTypes( $apiContext );
var_dump( $hooks->toArray() );